package com.ruoyi.nucleicacid.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nucleicacid.domain.Buildingtask;
import com.ruoyi.nucleicacid.service.IBuildingtaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 楼栋核酸任务Controller
 * 
 * @author kun
 * @date 2022-10-07
 */
@RestController
@RequestMapping("/nucleicacid/buildingtask")
public class BuildingtaskController extends BaseController
{
    @Autowired
    private IBuildingtaskService buildingtaskService;

    /**
     * 查询楼栋核酸任务列表
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:list')")
    @GetMapping("/list")
    public TableDataInfo list(Buildingtask buildingtask)
    {
        startPage();
        List<Buildingtask> list = buildingtaskService.selectBuildingtaskList(buildingtask);
        return getDataTable(list);
    }

    /**
     * 导出楼栋核酸任务列表
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:export')")
    @Log(title = "楼栋核酸任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Buildingtask buildingtask)
    {
        List<Buildingtask> list = buildingtaskService.selectBuildingtaskList(buildingtask);
        ExcelUtil<Buildingtask> util = new ExcelUtil<Buildingtask>(Buildingtask.class);
        util.exportExcel(response, list, "楼栋核酸任务数据");
    }

    /**
     * 获取楼栋核酸任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(buildingtaskService.selectBuildingtaskById(id));
    }

    /**
     * 新增楼栋核酸任务
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:add')")
    @Log(title = "楼栋核酸任务", businessType = BusinessType.INSERT)
    @PostMapping
    public void add(@RequestBody Buildingtask buildingtask) {
        buildingtaskService.insertBuildingtask(buildingtask);
    }

    /**
     * 修改楼栋核酸任务
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:edit')")
    @Log(title = "楼栋核酸任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Buildingtask buildingtask)
    {
        return toAjax(buildingtaskService.updateBuildingtask(buildingtask));
    }

    /**
     * 删除楼栋核酸任务
     */
    @PreAuthorize("@ss.hasPermi('nucleicacid:buildingtask:remove')")
    @Log(title = "楼栋核酸任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(buildingtaskService.deleteBuildingtaskByIds(ids));
    }
}
